{% extends "site_base.html" %}
{% load static %}
{% load i18n %}

{% block head_title %}{% if query %} - {{ query.title }}{% elif title %} - {{ title }}{% endif %}{% endblock %}

{% block extra_css %}
    <link rel="stylesheet" href="{% static 'select2/css/select2.min.css' %}?v={{ VERSION }}" />
    <link rel="stylesheet" href="{% static 'explorer/css/codemirror.min.css' %}" />
    <link rel="stylesheet" href="{% static 'explorer/css/pivot.min.css' %}" />
    <link rel="stylesheet" href="{% static 'c3/css/c3.min.css' %}?v={{VERSION}}" />
    <link rel="stylesheet" href="{% static 'explorer/css/explorer.css' %}" />
    <link rel="stylesheet" href="{% static 'explorer/css/qat-explorer.css' %}?v={{ VERSION }}" />
    <link rel="stylesheet" href="{% static 'qatrack_core/css/sidebar.css' %}?v={{VERSION}}" />
{% endblock extra_css %}

{% block extra_js %}
  <script type="text/javascript">
      queryId = "{% firstof query.id 'new' %}";
      csrfCookieName = "{% firstof csrf_cookie_name 'csrftoken' %}"
  </script>
{% endblock extra_js %}

{% block require_javascript %}
    require(['list', 'explorer', 'codemirror', 'codemirror/mode/sql/sql', 'codemirror/addon/comment/comment'], function(list, explorer, CodeMirror) {
      {% block sql_explorer_scripts %}
      {% endblock %}
    });
{% endblock require_javascript %}

{% block body_class %}sidebar-mini{% endblock body_class %}

{% block main_sidebar %}
<aside class="main-sidebar">
  <section class="sidebar">
    <ul class="sidebar-menu">
      <li class="header">{% trans "Reports Menu" %}</li>
      {% if can_view or can_change %}
      <li class="primary" title="{% trans "Click to run pre-defined reports" %}">
          <a href="{% url "explorer_index" %}">
            <i class="fa fa-play fa-fw" aria-hidden="true"></i>
            {% trans "Saved Reports" %}
          </a>
        </li>
      {% endif %}
      {% if can_change %}
      <li class="primary" title="{% trans "Click to create a new query" %}">
          <a href="{% url "query_create" %}">
            <i class="fa fa-file-text-o fa-fw" aria-hidden="true"></i>
            {% trans "New Query" %}
          </a>
        </li>
        <li class="primary" title="{% trans "Click to run ad-hoc queries" %}">
          <a href="{% url "explorer_playground" %}">
            <i class="fa fa-file-picture-o fa-fw" aria-hidden="true"></i>
            {% trans "Playground" %}
          </a>
        </li>
      {% endif %}
      {% if can_view or can_change %}
        <li class="primary" title="{% trans "Click to view history" %}">
          <a href="{% url "explorer_logs" %}">
            <i class="fa fa-history fa-fw" aria-hidden="true"></i>
            {% trans "History" %}
          </a>
        </li>
      {% endif %}
    </ul>
  </section>
</aside>
{% endblock main_sidebar %}

{% block body %}
  {% block sql_explorer_content_takeover %}
    <div id="wrap" class="wrap">
      <div class="{% block container_class %}container-fluid{% endblock container_class %}">
          <div class="starter-template">
          {% block sql_explorer_content %}{% endblock %}
          </div>
        </div>
    </div>
  {% endblock %}
{% endblock body %}

